package com.abuaziz.librarys

import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import com.abuaziz.librarys.LanguageSample.LanguageActivity
import com.abuaziz.librarys.Notification.NotificationTest
import com.abuaziz.librarys.ShapeViews.CustomShapeView
import com.abuaziz.librarys.UI.SharedPref.SharedPref
import com.abuaziz.librarys.model.HomeItem
import com.abuaziz.librarys.tset_adapter.AutoCompleteAdapter
import com.abuaziz.librarys.tset_adapter.RecyclerAdapter
import com.ug_project.adapters.createRecyclerAdapter
import com.ug_project.views.click
import com.ug_project.views.content
import com.ug_project.views.findTextView
import kotlinx.android.synthetic.main.activity_home.*
import me.ezitku.base.extensions.startActivity

class HomeActivity : BaseActivity() {


    var items = ArrayList<HomeItem>()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_home)

        items.add(HomeItem("ExpandRecyclerView", MainActivity::class.java))
        items.add(HomeItem("普通 Recycler Adapter", RecyclerAdapter::class.java))
        items.add(HomeItem("AutoCompleteAdapter", AutoCompleteAdapter::class.java))
        items.add(HomeItem("Notification", NotificationTest::class.java))
        items.add(HomeItem("Custom Shape View", CustomShapeView::class.java))
        items.add(HomeItem("语言本地化", LanguageActivity::class.java))
        items.add(HomeItem("SHaredPref 本地存储（XML）", SharedPref::class.java))
        recyclerView.layoutManager = LinearLayoutManager(this)


        recyclerView.adapter = createRecyclerAdapter(R.layout.item_home, items) {
            OnBindViewHolderIData { view, itemViewResID, data, position ->
                view.findTextView(R.id.item).content = data.title ?: ""
                view.click {
                    startActivity(data.dest)
                }
            }
        }
    }
}